extends NodeState


@export var player: Player



func _on_process(_delta : float) -> void:
	process_animation()



func _on_next_transitions() -> void:
	if player.inputManager.is_just_attack_input():
		process_ground_attack()
		return
	if player.inputManager.is_jump_input():
		transition_state(Player.STATE_TAKEOFF)
		return
	if player.inputManager.is_movement_input():
		transition_state(Player.STATE_WALK)
		return


func process_animation():
	player.animationPlayer.play(Player.ANIMATION_IDLE)


func process_ground_attack():
	var collectible := player.try_pickup_collectible()
	if collectible != null:
		transition_state(Player.STATE_PICKUP)
	elif player.has_knife:
		transition_state(Player.STATE_THROW)
	elif player.has_gun:
		if player.is_bullet_empty():
			transition_state(Player.STATE_THROW)
		else:
			transition_state(Player.STATE_SHOOT)
	else:
		transition_state(player.next_combo_attack_state())